package dict

/**
字典数据结构
*/

type Consumer func(key string, val interface{}) bool // 返回 true 继续遍历，返回 false 停止遍历

type Dict interface {
	Get(key string) (val interface{}, exists bool)
	Len() int
	Put(key string, val interface{}) (result int)
	PutIfAbsent(key string, val interface{}) (result int) // 没有才保存
	PutIfExists(key string, val interface{}) (result int) // 存在才保存
	Remove(key string) (result int)
	ForEach(consumer Consumer)
	Keys() []string
	RandomKeys(limit int) []string
	RandomDistinctKeys(limit int) []string // 返回不重复的键
	Clear()
}
